package com.ylfstu.string_;

/**
 * @author:Joy_Yang
 * @date:2022/9/28
 * @version:1.0
 */
public class String01 {
    public static void main(String[] args) {
        String name = "ylf";
        //name.intern();
        System.out.println(name.intern());

        String a = "hello";
        String b = "abc";
        //1.先创建一个StringBuilder sb = new StringBuilder();
        //2.执行 sb.append("hello")
        //3.sb.append("abc")
        //4.String c = sb.toString()
        //最后其实是 c 指向堆中的对象(String) value[] ->池中 "helloabc"
        String c = a + b;
        System.out.println(c);
        String d = "helloabc";
        System.out.println(c == d);//false ,c指向堆中String对象，d指向池中常量
        StringBuilder ab = new StringBuilder();
        ab.toString();
        String.valueOf(d);

    }
}
